home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / BlobMgr / Library Folder / Flags.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  3.2 KB  |  182 lines  |  [TEXT/KAHL]

  1. # include    "BlobMgr.h"
  2.  
  3.  
  4.  
  5. /* -------------------------------------------------------------------- */
  6. /*                     Blob Flag Manipulation Routines                    */
  7. /*                                                                        */
  8. /*    These routines operate only on the content of the blob state fields.*/
  9. /*    They do NOT do any redrawing or change the display in any way.        */
  10. /*                                                                        */
  11. /* -------------------------------------------------------------------- */
  12.  
  13.  
  14. pascal void
  15. SetBlobFlags (BlobHandle b, short bitMask)
  16. {
  17.     (**b).flags |= bitMask;
  18. }
  19.  
  20.  
  21. pascal void
  22. ClearBlobFlags (BlobHandle b, short bitMask)
  23. {
  24.     (**b).flags &= ~bitMask;            /* what's the operator here? */
  25. }
  26.  
  27.  
  28. /*
  29.  * Test the function result to be sure it's equal to the bitMask
  30.  * passed in, if exact match is required.
  31.  */
  32.  
  33. pascal short
  34. TestBlobFlags (BlobHandle b, short bitMask)
  35. {
  36.     return ((**b).flags & bitMask);
  37. }
  38.  
  39.  
  40. pascal void
  41. EnableBlob (BlobHandle b)
  42. {
  43.     SetBlobFlags (b, bEnableMask);
  44. }
  45.  
  46.  
  47. pascal void
  48. EnableBlobSet (BlobSetHandle bSet)
  49. {
  50.     BlobLoopProc1 (&EnableBlob, bSet);
  51. }
  52.  
  53.  
  54. pascal void
  55. DisableBlob (BlobHandle b)
  56. {
  57.     ClearBlobFlags (b, bEnableMask);
  58. }
  59.  
  60.  
  61. pascal void
  62. DisableBlobSet (BlobSetHandle bSet)
  63. {
  64.     BlobLoopProc1 (&DisableBlob, bSet);
  65. }
  66.  
  67.  
  68. pascal short
  69. GetBDrawMode (BlobHandle b, short partCode)
  70. {
  71. short    mask;
  72.  
  73.     mask = 0;
  74.     switch (partCode)
  75.     {
  76.         case inDragBlob: mask = bDragModeMask; break;
  77.         case inStatBlob: mask = bStatModeMask; break;
  78.     }
  79.     return (TestBlobFlags (b, mask) == mask ? dimDraw : normalDraw);
  80. }
  81.  
  82.  
  83. pascal void
  84. SetBDrawMode (BlobHandle b, short partCode, short mode)
  85. {
  86. short    mask;
  87.  
  88.     switch (partCode)
  89.     {
  90.         case inFullBlob: mask = bDrawModeMask; break;
  91.         case inDragBlob: mask = bDragModeMask; break;
  92.         case inStatBlob: mask = bStatModeMask; break;
  93.     }
  94.     if (mode == dimDraw)
  95.         SetBlobFlags (b, mask);
  96.     else
  97.         ClearBlobFlags (b, mask);
  98. }
  99.  
  100.  
  101. pascal short
  102. GetFzBDrawMode (BlobHandle b, short partCode)
  103. {
  104. short    mask;
  105.  
  106.     mask = 0;
  107.     switch (partCode)
  108.     {
  109.         case inDragBlob: mask = bDragModeMask; break;
  110.         case inStatBlob: mask = bStatModeMask; break;
  111.     }
  112.     return (((**b).fzFlags & mask) == mask ? dimDraw : normalDraw);
  113. }
  114.  
  115.  
  116.  
  117. pascal Boolean
  118. BlobDimmed (BlobHandle b, short partCode)
  119. {
  120. short    bitMask;
  121.  
  122.     switch (partCode)
  123.     {
  124.         case inFullBlob: bitMask = bDrawModeMask; break;
  125.         case inStatBlob: bitMask = bStatModeMask; break;
  126.         case inDragBlob: bitMask = bDragModeMask; break;
  127.     }
  128.     return (TestBlobFlags (b, bitMask) == bitMask);
  129. }
  130.  
  131.  
  132. pascal Boolean
  133. BlobEnabled (BlobHandle b)
  134. {
  135.     return (TestBlobFlags (b, bEnableMask) == bEnableMask);
  136. }
  137.  
  138.  
  139. pascal Boolean
  140. BlobFrozen (BlobHandle b)
  141. {
  142.     return (TestBlobFlags (b, bFreezeMask) == bFreezeMask);
  143. }
  144.  
  145.  
  146. /*
  147.  * Active = enabled, but not frozen.
  148.  */
  149.  
  150. pascal Boolean
  151. BlobActive (BlobHandle b)
  152. {
  153.     return (TestBlobFlags (b, bEnableMask | bFreezeMask) == bEnableMask);
  154. }
  155.  
  156.  
  157. /*
  158.  * Return true if the blob can be glued to another blob.  This is true
  159.  * if the blob is infinitely gluable or the current glue count is less
  160.  * than the blob's maximum glue count.
  161.  */
  162.  
  163. pascal Boolean
  164. CanGlue (BlobHandle b)
  165. {
  166. short    glueMax;
  167.  
  168.     glueMax = GetBGlueMax (b);
  169.     return (glueMax == infiniteGlue || glueMax > (**b).glueCount);
  170. }
  171.  
  172.  
  173. /*
  174.  * Return true if the blob is a picture blob, false if it's a
  175.  * procedure blob
  176.  */
  177.  
  178. pascal Boolean
  179. PicBlob (BlobHandle b)
  180. {
  181.     return (TestBlobFlags (b, bPicMask) == bPicMask);
  182. }